#!/bin/bash

# 建议证书路径/IP/证书有效日期都以参数形式传入


ES_HOME="$ELASTICSEARCH_HOME"

export ES_PATH_CONF="/opt/edp/${service.serviceName}/conf"

/usr/bin/expect -d >/dev/null 2>&1 <<EOF
set time 30
spawn sh /home/elasticsearch/elasticsearch/bin/elasticsearch-certutil cert --ca /home/elasticsearch/elasticsearch/config/elastic-stack-ca.p12 --out /opt/edp/${service.serviceName}/conf/elastic-certificates.p12 --days 3650 --ip `hostname -I`
expect "Enter password for CA*"
send "\n\r"
expect "Please enter the desired output file*"
send "\n\r"
expect "Enter password for*"
send "\n\r"
expect eof
EOF